//
//  YRunHomeCell.m
//  DefendHealth
//
//  Created by UNOHACHA on 17/3/7.
//  Copyright © 2017年 iMacOne. All rights reserved.
//

#import "YRunHomeCell.h"

@implementation YRunHomeCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
     
        UIView * bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 125)];
        bgView.backgroundColor = kWhiteColor;
        [self.contentView addSubview:bgView];
        
        
        UIImageView * mainUserImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(18, 12, 39, 39) imageName:@"" isCorner:YES];
        mainUserImg.backgroundColor = kRedColor;
         [bgView addSubview:mainUserImg];
        
        UIImageView * sexImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(kMaxX(mainUserImg.frame)-15, kMaxY(mainUserImg.frame)-15, 15, 15) imageName:@"small_feman" isCorner:NO];
        [bgView addSubview:sexImg];
        
        
       
        
        
        CGFloat  titWeight = kScreenWidth/2-kMaxX(mainUserImg.frame)-24;
        
        UILabel * TitL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(mainUserImg.frame)+12, mainUserImg.y, titWeight, 15) title:@"范大宝" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentLeft];
//        TitL.backgroundColor = kYellowColor;
//        TitL.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
        [bgView addSubview:TitL];
        
        UILabel * listID = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(mainUserImg.frame)+12,kMaxY(TitL.frame)+6, titWeight/2, 13) title:@"ID 1093" titleColor:UIColorFromRGB(0x666666) font:13 textAlignment:NSTextAlignmentLeft];
//        listID.backgroundColor = kBlackColor;
        [bgView addSubview:listID];
        
        
        UILabel * style = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(listID.frame), kMaxY(TitL.frame)+6, titWeight/2, 13) title:@"| 进行中" titleColor:UIColorFromRGB(0xea6229) font:13 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:style];
//
        CGFloat weight = kScreenWidth/6;
        
        
        UILabel * startTimL = [ReduceCode creatLabelWithFrame:CGRectMake(kScreenWidth/2-12, mainUserImg.y, weight, 15) title:@"18:00" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:startTimL];
        
        UILabel * TimeL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(startTimL.frame), startTimL.y, weight, 15) title:@"00:20" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:TimeL];
        
        UILabel * mileageL = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(TimeL.frame), startTimL.y, weight, 15) title:@"20 km" titleColor:UIColorFromRGB(0x333333) font:15 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:mileageL];
        
        
        UILabel * startTimStr = [ReduceCode creatLabelWithFrame:CGRectMake(kScreenWidth/2-12, listID.y, weight, 13) title:@"开始时间" titleColor:UIColorFromRGB(0x666666) font:13 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:startTimStr];
        
        UILabel * TimeStr = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(startTimStr.frame), listID.y, weight, 13) title:@"所用时间" titleColor:UIColorFromRGB(0x666666) font:13 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:TimeStr];

        UILabel * mileageStr = [ReduceCode creatLabelWithFrame:CGRectMake(kMaxX(TimeStr.frame), listID.y, weight, 13) title:@"里程进度" titleColor:UIColorFromRGB(0x666666) font:13 textAlignment:NSTextAlignmentLeft];
        [bgView addSubview:mileageStr];
        
        
        
        UIProgressView *processView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
        processView.frame = CGRectMake(18, kMaxY(style.frame)+18,kScreenWidth-36,4);
        processView.progress = 0.6;
        processView.trackTintColor = kLineColor;
         processView.progressTintColor = UIColorFromRGB(0xea6229);
        [bgView addSubview:processView];
        
        NSArray * userA = @[@"small_feman",@"small_man",@"small_feman",@"small_man",@"small_feman",@"small_man"];
        UIImageView * img = nil;
        
        for (NSInteger sex = 0;sex<6; sex++) {
            if (sex!= 5) {
              UIImageView * userImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(18+35*sex, kMaxY(processView.frame)+20, 30, 30) imageName:userA[sex]isCorner:YES];
              [bgView addSubview:userImg];
                img = userImg;
            }else {
                UILabel * overL = [ReduceCode creatLabelWithFrame:CGRectMake(18+35*sex,0, 30, 13) title:@"6/6" titleColor:UIColorFromRGB(0x666666) font:13 textAlignment:NSTextAlignmentLeft];
                overL.centerY = img.centerY;
                 [bgView addSubview:overL];
            }
            
        }

        
        UIImageView * rightImg = [ReduceCode creatImageVeiwWithFrame:CGRectMake(kScreenWidth-18-7, 0, 7, 12) imageName:@"next" isCorner:NO];
         rightImg.centerY = img.centerY;
        [bgView addSubview:rightImg];
        
        
    }
    
    return self;
    
    
}

@end
